package com.eduprocess.viewmodel;

public class Page {
	/** 当前页 */
	private int current = 1;
	/** 总记录数 */
	private int totals = 0;
	/** 总页数 */
	private int pages = 1;
	/** 每页记录数 */
	private int rows = 15;
	/** 下一页 */
	private int next = 1;
	/** 上一页 */
	private int previous = 1;

	public int getCurrent() {
		return current;
	}

	public void setCurrent(int current) {
		this.current = current;
	}

	public int getTotals() {
		return totals;
	}

	public void setTotals(int totals) {
		this.totals = totals;

		if (totals == 0) {
			this.pages = 1;
		} else {
			this.pages = (this.totals % this.rows == 0) ? this.totals
					/ this.rows : (this.totals / this.rows + 1);
		}

		if (this.pages <= 0)
			this.pages = 1;

		// next and previous
		previous = (current - 1 > 0) ? (current - 1) : 1;
		next = (current + 1 < pages) ? (current + 1) : pages;

	}

	public int getPages() {
		return pages;
	}

	public void setPages(int pages) {
		this.pages = pages;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public int getNext() {
		return next;
	}

	public void setNext(int next) {
		this.next = next;
	}

	public int getPrevious() {
		return previous;
	}

	public void setPrevious(int previous) {
		this.previous = previous;
	}

}
